Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check for positive xsize/ysize in ImagingFliDecode #8406

Closed
wants to merge 1 commit into from

Conversation

Yay295
Copy link
Contributor

@Yay295 Yay295 commented Sep 23, 2024

Fixes #8405

I put the check near the top, but is there any valid reason xsize or ysize would be 0, and the check would need to be later in the code?

@radarhere
Copy link
Member

is there any valid reason xsize or ysize would be 0

No. Images that say one of their dimensions are zero will be stopped at

Pillow/src/PIL/ImageFile.py

Lines 154 to 156 in 731bcda

if not self.mode or self.size[0] <= 0 or self.size[1] <= 0:
msg = "not identified by this driver"
raise SyntaxError(msg)

Even if you consider just the C decoding process, we have

Pillow/src/decode.c

Lines 189 to 192 in 731bcda

if (state->xsize <= 0 || state->xsize + state->xoff > (int)im->xsize ||
state->ysize <= 0 || state->ysize + state->yoff > (int)im->ysize) {
PyErr_SetString(PyExc_ValueError, "tile cannot extend outside image");
return NULL;

@radarhere
Copy link
Member

My minor concern with this strategy is that we could make someone reading the code think that xsize might be zero, which as I've said, shouldn't happen.

I've created #8408 as an alternative to this.

@radarhere
Copy link
Member

#8408 has been merged instead.

@radarhere radarhere closed this Sep 30, 2024
@Yay295 Yay295 deleted the patch-1 branch September 30, 2024 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unused code in FliDecode.c and _imaging.c has SAST security issue
2 participants